0, This version of Visual Basic includes an exciting new feature: the ability to create your own ActiveX controls.
7, In this demonstration, we'll look at building and testing a simple ActiveX control.
13, The first thing to do in building an ActiveX control is to simply select ActiveX Control from the New Project dialog.
20, We'll go ahead and choose OK and this will create a project with a single UserControl in it.
26, Now UserControl is, in many ways, very similar to a form, in that you can add other controls to it and it has a code module, as well, for writing code for that control.
36, The difference is that a UserControl is designed to be used on other forms instead of as a stand-alone form.
43, Now that we have our UserControl created, we need to add some functionality to it.
47, What we're going to do in this demonstration is create a simple clock control.
50, So, the first thing I'll do is add a label control to the UserControl.
55, And this label control will be used to display the current date and time.
59, Next, I'll add a timer control to the form that will actually control displaying the clock.
65, I'll set the Interval property of that timer to 1000, so that the timer controls Timer event fires every second.
73, Then, in the timer event procedure, we'll write code to simply put the current date and time into the label.
81, So, we'll say Label1.Caption = Now, and that's it for creating an ActiveX control.
94, However, since controls aren't designed to run on their own, we also need another project for testing our control.
100, So, I'll go ahead and add another project to this project group.
104, We'll go ahead and add a Standard EXE.
106, And we'll just resize the form a little bit, we don't need it quite this big for our control.
111, And now, in order to place the control on the form, what I need to do is actually close all of the control windows.
118, You'll notice when I close the last control window that the control actually appears on the toolbox.
123, And now I can actually draw my new control.
127, The other thing to notice here is as soon as I draw this control on the form it starts running.
132, Notice that the clock is updating and the timer control is actually firing every second here and refreshing that clock.
140, This is something important to note about UserControls, is that they actually run even when the project is still in design mode.
148, Now if we need to go change something in that control, as soon as I open a window for this control, notice now, that the control on the form has been suspended, so that it's no longer executing.
159, And if I close the window to the control again, it'll also continue executing.
164, So, what we've seen in this demonstration is building a simple ActiveX control and using that control in a client application.